#pragma once

#include <locale>
#include <string>
#include <codecvt>

namespace sqlite {
	namespace utility {
		inline std::string utf16_to_utf8(const std::u16string &input) {
#if _MSC_VER >= 1900
			std::wstring_convert<std::codecvt_utf8_utf16<int16_t>, int16_t> convert;
			return convert.to_bytes(reinterpret_cast<const int16_t *>(input.data()));
#else
			std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> convert;
			return convert.to_bytes(input);
#endif
		}
		inline std::string utf16_to_utf8(const std::wstring &input) {
			std::wstring_convert<std::codecvt_utf8<wchar_t>> convert;
			return convert.to_bytes(input);
		}
		inline std::wstring utf8_to_utf16(const std::string &input) {
			std::wstring_convert<std::codecvt_utf8<wchar_t>> convert;
			return convert.from_bytes(input);
		}
	} // namespace utility
} // namespace sqlite
